class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable

  enum role: { general: 0, admin: 1 }

  roles.keys.each do |role_name|
    define_method("#{role_name}?") do
      self.role == role_name
    end
  end

end
